package cn.iocoder.yudao.module.wine.controller.app.messageboard;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.wine.controller.app.messageboard.vo.*;
import cn.iocoder.yudao.module.wine.dal.dataobject.messageboard.MessageBoardDO;
import cn.iocoder.yudao.module.wine.service.messageboard.MessageBoardService;

@Tag(name = "用户 APP - 用户留言板")
@RestController
@RequestMapping("/wine/message-board")
@Validated
public class AppMessageBoardController {

    @Resource
    private MessageBoardService messageBoardService;

    @PostMapping("/create")
    @Operation(summary = "发布用户留言")
    public CommonResult<Long> createMessageBoard(@Valid @RequestBody AppMessageBoardSaveReqVO createReqVO) {
        return success(messageBoardService.appCreateMessageBoard(createReqVO));
    }

//    @DeleteMapping("/delete")
//    @Operation(summary = "删除用户留言板")
//    @Parameter(name = "id", description = "编号", required = true)
//    public CommonResult<Boolean> deleteMessageBoard(@RequestParam("id") Long id) {
//        messageBoardService.deleteMessageBoard(id);
//        return success(true);
//    }

//    @GetMapping("/get")
//    @Operation(summary = "获得用户留言板")
//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
//    public CommonResult<AppMessageBoardRespVO> getMessageBoard(@RequestParam("id") Long id) {
//        MessageBoardDO messageBoard = messageBoardService.getMessageBoard(id);
//        return success(BeanUtils.toBean(messageBoard, AppMessageBoardRespVO.class));
//    }

    @GetMapping("/dialog-list")
    @Operation(summary = "获得用户留言对话框")
    public CommonResult<List<AppMessageBoardRespVO>> getMessageBoardDialog(@Valid AppMessageBoardPageReqVO pageReqVO) {
        List<AppMessageBoardRespVO> list = messageBoardService.appGetMessageBoardDialog(pageReqVO);
        return success(list);
    }

    @GetMapping("/content-list")
    @Operation(summary = "获得用户所有留言内容")
    public CommonResult<List<AppMessageBoardRespVO>> getMessageBoardList(@Valid AppMessageBoardContentListReqVO listReqVO) {
        List<MessageBoardDO> list = messageBoardService.appGetMessageBoardList(listReqVO);
        return success(BeanUtils.toBean(list, AppMessageBoardRespVO.class));
    }

    @GetMapping("/supply-content-list")
    @Operation(summary = "从供求信息获得用户所有留言内容")
    public CommonResult<List<AppMessageBoardRespVO>> getMessageBoardList(@Valid AppSupplyMessageBoardReqVO reqVO) {
        List<MessageBoardDO> list = messageBoardService.appSupplyGetMessageBoardList(reqVO);
        return success(BeanUtils.toBean(list, AppMessageBoardRespVO.class));
    }

}
